<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <div id="app">


  </div>
  <!-- 引入React依赖 -->
  <script src="../React/react.development.js"></script>
  <script src="../React/react-dom.development.js"></script>
  <script src="../React/babel.min.js"></script>

  <!-- 编写React代码 -->
  <script type="text/babel">
    class App extends React.Component {
      constructor() {
        super()
        //定义变量
        this.state = {
          message: "Hello World",
          movies: ["大话西游", "盗梦空间", "星际穿越", "流浪地球"],
        }
      }
      render() {
        return (
          <div>
            <button onClick={() => { this.btnClick() }}>按钮</button>

            <ul>
              {this.state.movies.map((item, index) => {
                return (
                  <li onClick={() => { this.liClick(item, index) }}>
                    {item}
                  </li>
                )
                // return <li onClick={this.liClick(item)}>{item}</li>

              })}
            </ul>
          </div>
        )
      }

      btnClick() {
        console.log(event);
      }

      liClick(item, index) {
        console.log(item, index, event);
        // console.log(event);


      }
    }
  </script>

  <script type="text/babel">
    ReactDOM.render(<App />, document.getElementById("app"))
  </script>

</body>

</html>